﻿using FangChanCrm.Services.Interface;
using Maticsoft.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace FangChanCrm
{
    public class TimerHelper : Microsoft.Extensions.Hosting.BackgroundService
    {
        private readonly It_XiaoXiTiXingBiaoService t_XiaoXiTiXingBiaoService;
        private readonly It_RenYuanBiaoService t_RenYuanBiaoService;

        public TimerHelper(It_XiaoXiTiXingBiaoService xiaoXiTiXingBiaoService, It_RenYuanBiaoService renYuanBiaoService)
        {
            t_XiaoXiTiXingBiaoService = xiaoXiTiXingBiaoService;
            t_RenYuanBiaoService = renYuanBiaoService;
        }

        public TimerHelper()
        {
        }

        protected async override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                await new TaskFactory().StartNew(() =>
                {
                    try
                    {
                        string value = DateTime.Now.ToString();
                        var time = DateTime.Now.Hour;
                        //if (8 == time || 9 == time || 10 == time || 11 == time || 12 == time || 13 == time || 14 == time || 15 == time || 16 == time || 17 == time || 18 == time)
                        //{
                        //    SendMessage();
                        //}
                        Console.WriteLine("123");
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    Thread.Sleep(1 * 60000);
                });
            }
        }
        public override Task StartAsync(CancellationToken cancellationToken)
        {
            return ExecuteAsync(cancellationToken);
        }
    }
}
